package app.server.project.main.service.db.dao.user;

import app.server.project.main.service.db.entity.user.UserExtEntity;
import app.server.project.main.service.service.LockService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

@AllArgsConstructor
@Component
public class UserExtLock {

    private final UserExtDao userExtDao;
    private final LockService lockService;

    public UserExtEntity getUserExtByUserExtId(long userId) {
        var lock = lockService.getLock(userId);
        synchronized (lock) {
            return this.userExtDao.getInfoById(userId);
        }
    }
}
